package com.demo.wormhole.component.fegin.interceptor;

import com.demo.wormhole.core.context.WormholeContext;
import com.demo.wormhole.core.context.WormholeContextHolder;
import feign.RequestInterceptor;
import feign.RequestTemplate;

public class WormholeFeignRequestInterceptor implements RequestInterceptor {
    
    @Override
    public void apply(RequestTemplate requestTemplate) {
        WormholeContext wormholeContext = WormholeContextHolder.getContext();
        if (null != wormholeContext) {
            requestTemplate.header(WormholeContextHolder.WORMHOLE_REQUEST_MARK, wormholeContext.toString());
        }
    }
}
